from django.http import HttpResponseRedirect
from django.urls import reverse


def login_check(func):
    def check(request):
        try:
            request.session['user_id']
            return func(request)
        except:
            return HttpResponseRedirect(reverse('user:login'))
    return check